﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using WhereAmiMvc.Entities;
using WhereAmiMvc.ViewModel;

namespace WhereAmiMvc.Controllers
{
    public class DailyLogsController : Controller
    {
        DailyLogsBll logBll = new DailyLogsBll();
        EmployeesOfLocationBll emBll = new EmployeesOfLocationBll();
        // GET: DailyLogs
        public ActionResult Index()
        {
            var emlist = emBll.GetAll();
            return View(emlist);
        }

        // GET: DailyLogs/Details/5
        public ActionResult Details(string id)
        {
            var em = emBll.GetByKey(id);

            var logs = logBll.GetByCondition("*", string.Format(" AND IdEmployee ='{0}'", id));

            V_DailyLocation vdl = new V_DailyLocation();

            vdl.Employees = em;
            vdl.DailyLocationList = logs;
            
            return View(logs);
        }

        // GET: DailyLogs/Create
        public ActionResult Create()
        {
            return View();
        }

        // POST: DailyLogs/Create
        [HttpPost]
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                // TODO: Add insert logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        // GET: DailyLogs/Edit/5
        public ActionResult Edit(int id)
        {
            return View();
        }

        // POST: DailyLogs/Edit/5
        [HttpPost]
        public ActionResult Edit(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add update logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        // GET: DailyLogs/Delete/5
        public ActionResult Delete(int id)
        {
            return View();
        }

        // POST: DailyLogs/Delete/5
        [HttpPost]
        public ActionResult Delete(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add delete logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
    }
}
